<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>管理员页面</title>
    <link rel="icon" href="/image/favicon.ico" type="image/x-icon">
    <link rel="stylesheet" href="css/Admin.css">
</head>
<body>
<div id="img1">
    <img src="image/logo2.png">
    <div id="user">
        <ul>
            <li><a href="#">严打违规盗版文件和侵权传播</a></li>
            <li><a href="#">官方微博</a></li>
            <li><a href="#">问题反馈</a></li>
            <li><a href="#">客服联系</a></li>
        </ul>
    </div>
</div>
<div id="text">
    <div id="text1">
        <p>管理员登录</p>
    <div id="text2">
        <form  method="post" id="form">
            <input type="text" name="adminName" placeholder="用户名" id='adminName'>
            <input type="password" name="adminpassword" placeholder="密码" login="^\w{6,15}$" id="adminpassword">
            <span class="erorr" style="display: none">格式6-15位的英文或数字和下划线</span>
            <input type="button" value="登陆"  onclick="login();">
        </form>
       
        </div>
    </div>

</div>

<iframe src="footer.html" frameborder="0" scrolling="no" class="iframe"></iframe>
<script type="text/javascript" src="https://cdn.bootcss.com/jquery/2.2.2/jquery.js"></script>
<script src="https://cdn.bootcss.com/twitter-bootstrap/3.4.0/js/bootstrap.min.js"></script>
<script src="https://cdn.bootcss.com/layer/2.3/layer.js"></script>
<script>
    $(function (a) {
        $('#adminpassword').on('input', function (e) {   //密码格式是否正确
            var adminpassword = $(this).attr('login');
            var pw = new RegExp((adminpassword));
            if (pw.test($(this).val())) {
                $('.erorr').hide();
            }
            else{
                $('.erorr').show();
            }
        })
    })
    function login(){
        var adminName = $('#adminName').val();
        var adminpassword = $('#adminpassword').val();
        $.ajax({
            url:'/pan/admin/login',
            type:'post',
            data:{adminName:adminName,adminpassword:adminpassword},
            success:function(data){
                if(data.statusCode==400){
                	var message = data.data;
                	alert(message);
                }else{
                	layer.alert("登录成功", {icon: 5});
                   /*  window.open('adminIndex.html'); */
                	window.location.href=('adminIndex.html');
                }
               console.log(data);
            },
            error:function(err){
                console.log(err);
            }
        });
    }
</script>

</body>

</html>